import request from "../util/request.ts";
import { DeviceType } from ".-type/model.ts";

// 获取设备类型分页数据
export const fetchDeviceTypePage = async (currentPage: number, pageSize: number, deviceType: Partial<DeviceType>, during: string[]): Promise<any> => {
    return await request.get(`/device-type/page`, {
        params: {
            currentPage,
            pageSize,
            deviceType: JSON.stringify(deviceType),
            during: during ? during.join(',') : []
        }
    });
}

// 获取所有设备类型数据
export const fetchAllDeviceType = async (): Promise<any> => {
    return await request.get(`/device-type/all`);
}

// 添加设备类型
export const postDeviceType = async (deviceType: DeviceType): Promise<any> => await request.post("/device-type", deviceType);

// 更新设备类型
export const putDeviceType = async (deviceType: DeviceType): Promise<any> => await request.put("/device-type", deviceType);

// 删除设备类型
export const delDeviceType = async (id: number): Promise<any> => await request.delete(`/device-type/${id}`);

// 批量删除设备类型
export const batchDelDeviceType = async (ids: number[]): Promise<any> => await request.delete("/device-type/batch/delete", {
    params: {
        ids: ids.join(',')
    }
});

// 导出设备类型数据
export const exportDeviceTypeData = async (): Promise<any> => await request.get("/device-type/export", { responseType: "blob" });

// 获取设备类型信息
export const fetchDeviceTypeInfo = async (): Promise<any> => await request.get("/device-type/info");

// 根据ID获取设备类型
export const fetchDeviceTypeById = async (id: number): Promise<any> => {
    return await request.get(`/device-type/${id}`);
}
